package com.vhly.ddxdecompiler.dexreader.file.dalv.code;

import com.vhly.ddxdecompiler.dexreader.io.DexInputStream;

import java.io.IOException;
import java.util.Vector;

/**
 * Created by IntelliJ IDEA.
 * User: vhly
 * Date: 2009-10-21
 * Time: 13:29:13
 *
 * @author vhly[FR]
 */

/**
 * 描述 Dalv 指令的对象
 */
public abstract class DalvInsn {

    public static final int INSN_ARRAYDATA = 768;
    public static final int INSN_SWITCHDATA_PACK = 256;
    public static final int INSN_SWITCHDATA = 512;

    protected int opcode;
    protected Dop dexOpcode;
    protected Vector<Integer> registers;

    public DalvInsn() {
        registers = new Vector<Integer>();
    }

    public Dop getOpcode() {
        return dexOpcode;
    }

    /**
     *
     * @param din
     * @return 读取的short长度
     * @throws IOException
     */
    public abstract int read(DexInputStream din) throws IOException;

    public void addRegister(int reg) {
        registers.add(reg);
    }

    /**
     * 转换为Java ByteCode
     *
     * @return byte[]
     */
    public abstract byte[] reverseJava();
}
